/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */
var findTargetSumWays = function (nums, target) {
  let cnt = 0;

  function dfs(idx, target) {
    if (idx == nums.length) {
      if (target == 0) cnt++;
      return;
    }
    dfs(idx + 1, target - nums[idx]);
    dfs(idx + 1, target + nums[idx]);
  }
  dfs(0, target);
  return cnt;

};
let nums = [1,1,1,1,1], target = 3;
console.log(findTargetSumWays(nums, target));
nums = [1], target = 1;
console.log(findTargetSumWays(nums, target));
